home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 June / EnigmA AMIGA RUN 08 (1996)(G.R. Edizioni)(IT)[!][issue 1996-06][EARSAN CD VII].iso / earcd / comm1 / intsdkss.lha / include / net / route.h < prev   
C/C++ Source or Header  |  1996-04-09  |  3KB  |  96 lines

  1. #ifndef NET_ROUTE_H
  2. #define NET_ROUTE_H
  3. /*
  4.  * Copyright (c) 1980, 1986 Regents of the University of California.
  5.  * All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms are permitted
  8.  * provided that the above copyright notice and this paragraph are
  9.  * duplicated in all such forms and that any documentation,
  10.  * advertising materials, and other materials related to such
  11.  * distribution and use acknowledge that the software was developed
  12.  * by the University of California, Berkeley.  The name of the
  13.  * University may not be used to endorse or promote products derived
  14.  * from this software without specific prior written permission.
  15.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  16.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  17.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  18.  *
  19.  *    @(#)route.h     7.4 (Berkeley) 6/27/88
  20.  */
  21.  
  22. /*
  23.  * Kernel resident routing tables.
  24.  *
  25.  * The routing tables are initialized when interface addresses
  26.  * are set by making entries for all directly connected interfaces.
  27.  */
  28.  
  29. /*
  30.  * A route consists of a destination address and a reference
  31.  * to a routing entry.    These are often held by protocols
  32.  * in their control blocks, e.g. inpcb.
  33.  */
  34. struct route {
  35.     struct    rtentry *ro_rt;
  36.     struct    sockaddr ro_dst;
  37. };
  38.  
  39. /*
  40.  * We distinguish between routes to hosts and routes to networks,
  41.  * preferring the former if available.    For each route we infer
  42.  * the interface to use from the gateway address supplied when
  43.  * the route was entered.  Routes that forward packets through
  44.  * gateways are marked so that the output routines know to address the
  45.  * gateway rather than the ultimate destination.
  46.  */
  47. struct rtentry {
  48.     u_long    rt_hash;        /* to speed lookups */
  49.     struct    sockaddr rt_dst;    /* key */
  50.     struct    sockaddr rt_gateway;    /* value */
  51.     short    rt_flags;        /* up/down?, host/net */
  52.     short    rt_refcnt;        /* # held references */
  53.     u_long    rt_use;         /* raw # packets forwarded */
  54.     struct    ifnet *rt_ifp;        /* the answer: interface to use */
  55. };
  56.  
  57. #define RTF_UP        0x1        /* route useable */
  58. #define RTF_GATEWAY    0x2        /* destination is a gateway */
  59. #define RTF_HOST    0x4        /* host entry (net otherwise) */
  60. #define RTF_DYNAMIC    0x10        /* created dynamically (by redirect) */
  61. #define RTF_MODIFIED    0x20        /* modified dynamically (by redirect) */
  62.  
  63. /*
  64.  * Routing statistics.
  65.  */
  66. struct    rtstat {
  67.     short    rts_badredirect;    /* bogus redirect calls */
  68.     short    rts_dynamic;        /* routes created by redirects */
  69.     short    rts_newgateway;     /* routes modified by redirects */
  70.     short    rts_unreach;        /* lookups which failed */
  71.     short    rts_wildcard;        /* lookups satisfied by a wildcard */
  72. };
  73.  
  74. #ifdef KERNEL
  75. #define RTFREE(rt) \
  76.     if ((rt)->rt_refcnt == 1) \
  77.         rtfree(rt); \
  78.     else \
  79.         (rt)->rt_refcnt--;
  80.  
  81. #ifdef    GATEWAY
  82. #define RTHASHSIZ    64
  83. #else
  84. #define RTHASHSIZ    8
  85. #endif
  86. #if    (RTHASHSIZ & (RTHASHSIZ - 1)) == 0
  87. #define RTHASHMOD(h)    ((h) & (RTHASHSIZ - 1))
  88. #else
  89. #define RTHASHMOD(h)    ((h) % RTHASHSIZ)
  90. #endif
  91. extern struct    mbuf *rthost[RTHASHSIZ];
  92. extern struct    mbuf *rtnet[RTHASHSIZ];
  93. extern struct    rtstat rtstat;
  94. #endif /* KERNEL */
  95. #endif
  96.